<template>
  <div class="swiper-container">
    <div class="swiper-wrapper">
      <div class="swiper-slide" v-for="v, i in imgList" :key="i">
        <img :src="v" alt="1">
      </div>
    </div>
    <!-- 如果需要分页器 -->
    <div class="swiper-pagination"></div>

  </div>
</template>
<script>
import Swiper from 'swiper'
export default {
  name: 'SamSwiper',
  components: {

  },
  props: ["imgList"],
  data() {
    return {
    }
  },
  mounted() {
    // 保证dom结构已经已经完全生成
    this.$nextTick(() => {
          //当执行这个回调的时候：保证服务器数据回来了，v-for执行完毕了
          new Swiper('.swiper-container', {
            // 如果需要分页器
            pagination: {
              el: '.swiper-pagination',
            },

            // 如果需要前进后退按钮
            navigation: {
              nextEl: '.swiper-button-next',
              prevEl: '.swiper-button-prev',
            },
          })
        })
  },
};
</script>
<style lang='less' scoped>
.swiper-container {
  width: 37.5rem;
  height: 30rem;
  margin-top: 4rem;
  img{
    width: 37.5rem;
  }
}
</style>